package com.mingqijia.gassafety.db.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mingqijia.gassafety.db.entity.Consumer;
import com.mingqijia.gassafety.db.entity.Contacts;
import com.mingqijia.gassafety.db.entity.FuncArea;
import com.mingqijia.gassafety.db.entity.MigrateConsumer;
import com.mingqijia.gassafety.db.entity.vo.ConsumerFuncAreaVo;
import com.mingqijia.gassafety.db.entity.vo.CustListAsstVO;
import com.mingqijia.gassafety.db.entity.vo.IndustryUnderUserListVo;
import com.mingqijia.gassafety.db.entity.vo.SpConsumerVo;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 用户表 Mapper 接口
 * </p>
 *
 * @author wanghai
 * @since 2022-02-22
 */
@Mapper
@Repository
public interface ConsumerMapper extends BaseMapper<Consumer> {

    String selectNames(@Param("spId") String spId, @Param("ids") String[] ids);


    Integer insertConsumer(MigrateConsumer consumer);
    List<Long> selectIdsBySpId(@Param("spId")String spId);

    String selectVccNames(@Param("spId") String spId, @Param("ids") String[] ids);


    List<CustListAsstVO> custlistAsst(@Param("spIds") List<String> spIds, @Param("industryType")String industryType, @Param("contactInfo") String contactInfo);



    // 根据设备号 获取对应设备及用户信息
    Map<String, Object> gasGasInfoByImei(@Param("iMEI")String iMEI, @Param("spId") String spId);

    List<Contacts> selectLevelContactsByConsumerId(@Param("consumerIds")List<Integer> consumerIds);

    void updateStatusByCode(@Param("subsCode")String subsCode);

    Consumer selectByOrgCode(@Param("subsCode")String subsCode, @Param("spId")String spId);

    String selectName(@Param("s") String s);

    Consumer selectSubsCodeByConsumerId(@Param("consumerId") Integer consumerId);

    Integer selectUserTypeCount(@Param("spId") String spId, @Param("custType") String custType);

    List<String> selectUserType(@Param("spId") String spId);

    List<Integer> getCustomerIdListByType(@Param("spId") String spId, @Param("custType") String custType);
    
    List<SpConsumerVo> getSpConsumerStat();

    //接入用户数
    Integer getUnderUserSum(@Param("spId") String spId, @Param("industryType") String industryType, @Param("adCode") String adCode,
                            @Param("townCode") String townCode, @Param("businessAreaCode") String businessAreaCode,
                            @Param("funcCodes") List<String> funcCodes);

    //接入用户列表
    List<IndustryUnderUserListVo> underUserList(@Param("spId") String spId, @Param("industryType") String industryType, @Param("adCode") String adCode,
                                          @Param("townCode") String townCode, @Param("businessAreaCode") String businessAreaCode, @Param("start") int start, @Param("pageSize") int pageSize,
                                                @Param("funcCodes") List<String> funcCodes);

    List<Integer> getDepartConsumerIds(@Param("spId") String spId, @Param("funcCodes") List<String> funcCodes);

    /**
     * 获取企业客户的功能区code
     * @param spId
     * @return
     */
    List<ConsumerFuncAreaVo> getConsumersFuncAreaCodes(@Param("spId") String spId,  @Param("funcCodes") List<String> funcCodes);

    //根据区域编码查询客户信息
    List<Integer> getCustomerLocationIdsByFuncCode(@Param("model") FuncArea model);

    Integer getConditionList(@Param("spIds") List<String> spIds,@Param("deviceStatusList") List<Integer> deviceStatusList);
}
